<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>AirWeb数据平台</title>

    <!-- Bootstrap -->
    <link href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
    <nav class="navbar navbar-default" role="navigation">
        <div class="container">
          <div class="navbar-header">
              <a class="navbar-brand" href="#">数据平台</a>
          </div>
          <div>
            <ul class="nav navbar-nav">
                <li><a href="/">首页</a></li>
                <li><a href="/real">实时数据</a></li>
                <li id="minnav"><a href="/his?type=1">分钟数据</a></li>
                <li id="hournav"><a href="/his?type=2">小时数据</a></li>
                <li id="daynav"><a href="/his?type=3">日数据</a></li>
            </ul>
          </div>
        </div>
    </nav>
    <table class="table table-bordered" id="realtable">
      <tr>
        <th>序号</th>
        <th>设备编号</th>
        <th>数据编码</th>
        <th>平均值</th>
        <th>最小值</th>
        <th>最大值</th>
        <th>数据时间</th>
        <th>插入时间</th>
      </tr>
    </table>
    <form class="form-horizontal" role="form" id="pageform">
      <div class="form-group">
        <label class="col-sm-offset-4 col-sm-2 control-label">第{{.PageNum}}页 共{{.PageAll}}页</label>
        <div class="col-sm-1">
          <input type="text" class="col-sm-0.5 form-control" id="pagenum" name="pagenum">
        </div>
        <button type="submit" class="col-sm-0.5 btn btn-default" id="pagejump"><strong>跳转</strong></button>
        <div><input type="hidden" id="type" name="type"></div>
        <div><input type="hidden" id="mn" name="mn"></div>
        <div><input type="hidden" id="code" name="code"></div>
      </div>
    </form>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>

    <script type="text/javascript">
    $(document).ready(tableinsert);

    function tableinsert()
    {
      var index = 0;
      {{range .HisData}}
      index++;
      var newRow = "<tr><td>" + index + "</td><td>{{.Mn}}</td><td>{{.Name}}</td>" + 
        "<td>{{.AvgValue}}</td><td>{{.MinValue}}</td><td>{{.MaxValue}}</td>" + 
        "<td>{{.DataTime}}</td><td>{{.InsertTime}}</td></tr>";
      $("#realtable tr:last").after(newRow);
      {{end}}
      
      $("#type").get(0).value = {{.HisType}}; 
      $("#mn").get(0).value = {{.HisMn}}; 
      $("#code").get(0).value = {{.HisCode}}; 

      if ($("#type").get(0).value == 1)
          $("#minnav").addClass('active');
      else if ($("#type").get(0).value == 2)
          $("#hournav").addClass('active');
      else if ($("#type").get(0).value == 3)
          $("#daynav").addClass('active');
    }
    </script>
  </body>
</html>